<template>
  <div>
    <h1>添加</h1>
    <van-field label="工作流名称" v-model="form.name"></van-field>
    <van-button round @click="add">添加</van-button>

    <h1>展示</h1>
    <table>
      <tr>
        <td>id</td>
        <td>名称</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in yewu">
        <td>{{ i.id }}</td>
        <td>{{ i.name }}</td>
        <td>
          <van-button @click="jump(i.id)">参数</van-button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "add_yewu",
  data() {
    return {
      form: {},
      yewu: []
    }
  },
  methods: {
    add() {
      this.$axios.post('/day01/yewu', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('添加成功')
            this.form = {}
          }
        })
    },
    get_yewu() {
      this.$axios.get('/day01/yewu')
        .then(res => {
          if (res.data.code == 200) {
            this.yewu = res.data.list
          }
        })
    },
    jump(id) {
      this.$router.push({path: '/add_parms', query: {'id': id}})
    }
  },
  mounted() {
    this.get_yewu()
  }
}
</script>

<style scoped>

</style>
